package com.zhike.function;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.PropertyNamingStrategy;
import com.alibaba.fastjson.serializer.SerializeConfig;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.zhike.bean.AlarmBean;

/**
 * @Author: zhike
 * @CreateTime: 2024/2/27 11:00
 * @Description:  将javaBean对象转换为json对象
 */
public class BeanToJsonFunction {
    public static <T>String getString(T value) {
        SerializeConfig serializeConfig = new SerializeConfig();
        serializeConfig.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase;
        return JSON.toJSONString(value, serializeConfig, SerializerFeature.WriteMapNullValue);
    }
}
